import UIKit

func addOne(num: Int) -> Int {
  return num + 1
}

func addTo(_ adder: Int) -> (Int) -> Int {
  return { num in
    num + adder
  }
}

let addTwo = addTo(2)
let result = addTo(6)
print(result)

// 比较大小的函数
func greatThan(_ compare: Int) -> (Int) -> Bool {
  return { $0 > compare }
}

let greatThan10 = greatThan(10)
greatThan10(20)
greatThan10(200)


protocol TargetAction {
	func performAction()
}

struct TargetActionWrapper<T: AnyObject>:
	TargetAction {
	weak var target: T?
	let action: (T) -> () -> ()
	
	func performAction() -> () {
		if let t = target {
			action(t)()
		}
	}
}

enum ControlEvent {
	case TouchUpInside
	case ValueChanged
		// ...
}

